/*
 * main.cpp
 *
 *  Created on: 11 Oct 2012
 *      Author: Mario Kleinsasser
 *		Time:	19:01:45
 */

#include <iostream>

#include "CEnvironment.h"
#include "CAreaList.h"
#include "CAntSimGenericException.h"
#include "CItemFactory.h"
#include "CAnthill.h"
#include "CFood.h"
#include <ctime>
#include <stdlib.h>
#include <exception>
#include <list>
#include "CEmpty.h"
#include <unistd.h>

using namespace std;

/*
 * Really need to fix this print because its terrible
 * free flying code...
 */

int main(int argc, char *argv[]) {

	/* COMMIT VON MARIO 25.11.2012 08:43 */

	/* initialize random (only once in the whole program! */
	srand(time(NULL));
	//srand(42156445);
	/* create singelton of CEnvironment */

	CEnvironment &environment = CEnvironment::getInstance(8,8);

	/* Place the anthill an the food */
	CItemFactory *myGameFactory = new CItemFactory();

	CAnthill* anthill = dynamic_cast<CAnthill*>(myGameFactory->newItem("anthill"));
	environment.getPlayground()->getArea(anthill->getM(), anthill->getN())->addItemToList(anthill);

	CFood* food = dynamic_cast<CFood*>(myGameFactory->newItem("food"));
	environment.getPlayground()->getArea(food->getM(), food->getN())->addItemToList(food);

	/* Main game loop*/
	for (int i = 0; i <= 1000; i++) {
		system("clear");

		environment.printAll();

		environment.actAll();

		environment.setTurncnt(environment.getTurncnt() + 1);

		usleep(0.5 * 100000);
	}

	environment.destroy();

	return 0;
}

